package com.ruoyi.analysis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.analysis.domain.ProductAnalysisWelder;
import com.ruoyi.analysis.service.IProductAnalysisWelderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员生产数据Controller
 * 
 * @author ruoyi
 * @date 2023-01-04
 */
@Controller
@RequestMapping("/analysis/welder")
public class ProductAnalysisWelderController extends BaseController
{
    private String prefix = "analysis/welder";

    @Autowired
    private IProductAnalysisWelderService productAnalysisWelderService;

    @RequiresPermissions("analysis:welder:view")
    @GetMapping()
    public String welder()
    {
        return prefix + "/welder";
    }


    /**
     * 查询人员生产数据列表
     */
    @RequiresPermissions("analysis:welder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProductAnalysisWelder productAnalysisWelder)
    {
        startPage();
        List<ProductAnalysisWelder> list = productAnalysisWelderService.selectProductAnalysisWelderList(productAnalysisWelder);
        return getDataTable(list);
    }

    /**
     * 导出人员生产数据列表
     */
    @RequiresPermissions("analysis:welder:export")
    @Log(title = "人员生产数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProductAnalysisWelder productAnalysisWelder)
    {
        List<ProductAnalysisWelder> list = productAnalysisWelderService.selectProductAnalysisWelderList(productAnalysisWelder);
        ExcelUtil<ProductAnalysisWelder> util = new ExcelUtil<ProductAnalysisWelder>(ProductAnalysisWelder.class);
        return util.exportExcel(list, "人员生产数据数据");
    }

    /**
     * 新增人员生产数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员生产数据
     */
    @RequiresPermissions("analysis:welder:add")
    @Log(title = "人员生产数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProductAnalysisWelder productAnalysisWelder)
    {
        return toAjax(productAnalysisWelderService.insertProductAnalysisWelder(productAnalysisWelder));
    }

    /**
     * 修改人员生产数据
     */
    @RequiresPermissions("analysis:welder:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ProductAnalysisWelder productAnalysisWelder = productAnalysisWelderService.selectProductAnalysisWelderById(id);
        mmap.put("productAnalysisWelder", productAnalysisWelder);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员生产数据
     */
    @RequiresPermissions("analysis:welder:edit")
    @Log(title = "人员生产数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProductAnalysisWelder productAnalysisWelder)
    {
        return toAjax(productAnalysisWelderService.updateProductAnalysisWelder(productAnalysisWelder));
    }

    /**
     * 删除人员生产数据
     */
    @RequiresPermissions("analysis:welder:remove")
    @Log(title = "人员生产数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(productAnalysisWelderService.deleteProductAnalysisWelderByIds(ids));
    }
}
